
import java.util.Map;

public class SubMatrixAlignScore implements AlignmentScore {

	int[][] scoreMatrix;
	Map<String, Integer> strMapping;
	String str1;
	String str2;

	public void setStr1(String str1) {
		this.str1 = str1;
	}

	public void setStr2(String str2) {
		this.str2 = str2;
	}

	public void setSubMatrix(SubstitutionMatrix matrix) {
		scoreMatrix = matrix.getValueMatrix();
		strMapping = matrix.getXStrMapping();
	}

	public int score(int[][] matrix, int x, int y) {
		int subX = strMapping.get(str1.substring(x - 1, x)).intValue();
		int subY = strMapping.get(str2.substring(y - 1, y)).intValue();
		return scoreMatrix[subX][subY];
	}

}
